#include "AboutScene.h"
#include "MenuScene.h"

bool About::init() {
	if (!CCLayer::init()) {
		return false;
	}

	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();

	CCMenuItemImage *pBackItem = CCMenuItemImage::create("back.png", "back.png",
			this, menu_selector(About::menuBackCallback));
	pBackItem->setPosition(ccp(50, 30));
	CCMenu* pMenu = CCMenu::create(pBackItem, NULL);
	pMenu->setPosition(CCPointZero);
	this->addChild(pMenu, 1);

	CCSprite* pBackgroundSprite = CCSprite::create("bg.png");

	// position the sprite on the center of the screen
	pBackgroundSprite->setPosition(
			ccp(visibleSize.width/2, visibleSize.height/2));

	// add the sprite as a child to this layer
	this->addChild(pBackgroundSprite, 0);

	return true;
}

CCScene* About::scene() {
	// 'scene' is an autorelease object
	CCScene *scene = CCScene::create();

	// 'layer' is an autorelease object
	About *layer = About::create();

	// add layer as a child to scene
	scene->addChild(layer);

	// return the scene
	return scene;
}

void About::menuBackCallback(CCObject* pSender) {
	CCScene *pMenuScene = Menu::scene();
	CCDirector::sharedDirector()->setDepthTest(true);
	CCDirector::sharedDirector()->replaceScene(
			CCTransitionPageTurn::create(1, pMenuScene, true));
}
